// components/nav-bar/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    //显示隐藏标题栏
    show: {
      type: Boolean,
      value: true,
    },
    //回退键的显示隐藏
    back: {
      type: Boolean,
      value: true,
    },
    home: {
      type: Boolean,
      value: false,
    },
    custom_back: {
      type: Boolean,
      value: false,
    },
    //标题
    title: {
      type: String,
      value: "标题",
    },
    custom_style: {
      type: String,
      value: "",
    },
    // homeShow: {
    //   type: Boolean,
    //   value: false,
    // },
  },

  /**
   * 组件的初始数据
   */
  data: {},

  /**
   * 组件的方法列表
   */
  methods: {
    _onClickLeft() {
      let { custom_back, home, homeShow } = this.data;

      if (home) {
        // wx.navigateBack({ delta: 3 });
        wx.reLaunch({
          url: "/pages/index/index",
        });
      } else {
        if (custom_back) {
          this.triggerEvent("backEvent");
        } else {
          wx.navigateBack();
        }
      }
    },
    _onClickRight() {},
  },
  attached() {
    let page = this;
    while (page && !page.route) {
      page = page.selectOwnerComponent();
    }
    if (page && page.route) {
      page._pageName = this.data.title;
    }
  },
});
